package me.zhengjie.utils;


import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class WarmGradientImage {
public static void main(String[] args) {
        int width = 1000;
        int height = 1000;

        // 创建一个BufferedImage对象
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = image.createGraphics();

        // 设置渐变颜色
        Color startColor = new Color(244, 237, 233); // 浅橙色
        Color endColor = new Color(234, 186, 138);   // 深橙色

        // 创建渐变画笔
        GradientPaint gradient = new GradientPaint(
                0, 0, startColor,
                width / 2, height / 2, endColor,
                true
        );
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setPaint(gradient);
        g2d.fillRect(0, 0, width, height);

        // 添加对称效果
        g2d.drawLine(0, height / 2, width, height / 2);
        g2d.drawLine(width / 2, 0, width / 2, height);

        // 释放资源
        g2d.dispose();

        // 保存图片到文件
        try {
            File outputfile = new File("D:\\360Downloads\\warm_symmetric_gradient_image.jpg");
            ImageIO.write(image, "jpg", outputfile);
            System.out.println("Image created successfully!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
